home *** CD-ROM | disk | FTP | other *** search
/ Shareware Grab Bag / Shareware Grab Bag.iso / 003 / dbapg.arc / CHGCASE.CMD < prev    next >
Encoding:
Text File  |  1984-08-09  |  4.0 KB  |  123 lines

  1. * Program..: CHGCASE.CMD
  2. * Author...: Tom Rettig
  3. * Date.....: May 12, 1983
  4. * Notice...: Copyright 1983 by Ashton-Tate.  All rights reserved.
  5. * dBASE....: II, versions 2.3x, 2.4x
  6. * Notes....: For changing character fields from all uppercase
  7. *            to lowercase with the first letter capitalized.
  8. *
  9. *            Substitute "Char:field" with the field name in your datafile.
  10. *
  11. *            To change back to upper case, issue the command:
  12. *            REPLACE ALL Char:field WITH !(Char:field)
  13. *
  14. ERASE
  15. SET TALK OFF
  16. SET COLON OFF
  17. @ 1, 0 SAY "========================================"+;
  18.            "========================================"
  19. @ 2, 0 SAY "||"
  20. @ 2,19 SAY "C H A N G I N G   T O   L O W E R   C A S E"
  21. @ 2,78 SAY "||"
  22. @ 3, 0 SAY "========================================"+;
  23.            "========================================"
  24. *
  25. * Prompt user for current version of dBASE II.  
  26. STORE "?" TO version
  27. DO WHILE version <> "3" .AND. version <> "4"
  28.    @ 5,22 SAY "SELECT THE VERSION OF YOUR dBASE II:"
  29.    @ 7,28 SAY "TYPE <3> FOR VERSION 2.3"
  30.    @ 8,28 SAY "TYPE <4> FOR VERSION 2.4"
  31.    @ 11,34 SAY "Version = 2." GET version
  32.    READ
  33. ENDDO
  34. @ 5,10
  35. @ 7,20
  36. @ 8,20
  37. @ 11,20
  38. *
  39. * Version 2.3 does not have a RANK function like 2.4 does,
  40. * so create two strings in order to use a location number
  41. * instead of an ASCII number.
  42. IF version="3"
  43.    STORE "ABCDEFGHIJKLMNOPQRSTUVWXYZ" TO ucase
  44.    STORE "abcdefghijklmnopqrstuvwxyz" TO lcase
  45. ENDIF
  46. *
  47. USE Anyfile
  48. STORE (80-LEN(Char:field))/2 TO col
  49. DO WHILE .NOT. EOF
  50.    *
  51.    * Display the record number and uppercase field, and
  52.    * blank the previous lowercase field if there was one.
  53.    @ 10,col SAY Char:field
  54.    @ 11,col-8 SAY #
  55.    @ 12,col
  56.    *
  57.    * Initialize the memory variables.
  58.    STORE " " TO new:char
  59.    STORE F TO isreplace
  60.    STORE 0 TO count
  61.    *
  62.    * Loop to work on each character one at a time
  63.    * for the length of the field.
  64.    DO WHILE count < LEN(TRIM(Char:field))
  65.       STORE count+1 TO count
  66.       STORE $(Char:field,count,1) TO char
  67.       *
  68.       * Determine identity of character according to version.
  69.       IF version="3"
  70.          * 
  71.          * Find location number in uppercase string.
  72.          STORE @(char,ucase) to location
  73.          *
  74.          * If this character is in the uppercase string, and the
  75.          * previous character was also, then replace this character
  76.          * with the matching one from the lowercase string.
  77.          IF location <> 0 .AND. isreplace
  78.             STORE new:char+$(lcase,location,1) TO new:char
  79.          ELSE
  80.             * If this character is not in the uppercase string,
  81.             * or if the previous character was not there, 
  82.             * do not replace.
  83.             STORE new:char+char TO new:char
  84.          ENDIF
  85.          *
  86.       ELSE
  87.          * If this character is an uppercase letter, 
  88.          * and the previous character was also, then 
  89.          * replace with a lowercase letter.
  90.          IF char >= "A" .AND. char <= "Z" .AND. isreplace
  91.             STORE new:char+CHR( RANK(char)+32 ) TO new:char
  92.          ELSE
  93.             * If this character is not an uppercase letter,
  94.             * or if the previous character was not alphabetical,
  95.             * do not replace.
  96.             STORE new:char + char TO new:char
  97.          ENDIF
  98.       ENDIF
  99.       *
  100.       * Set the logical memvar to replace the next character only if
  101.       * this character is alphabetical (either upper or lower case).
  102.       STORE .NOT. ( (char > "Z" .AND. char < "a");
  103.                 .OR. char < "A"  .OR. char > "z" ) TO isreplace
  104.       *
  105.       * Display the new field as replacements are made.
  106.       * (removing this command will speed up the operation slightly)
  107.       @ 12,col-1 SAY new:char
  108.    ENDDO
  109.    REPLACE Char:field WITH $(new:char,2,LEN(TRIM(Char:field))+1)
  110.    SKIP
  111. ENDDO
  112. @ 10,0
  113. @ 11,0
  114. @ 12,0
  115. @ 12,12 SAY "********** C H A N G E   I S   C O M P L E T E **********"
  116. USE Anyfile
  117. RELEASE ALL
  118. SET COLON ON
  119. SET TALK ON
  120. RETURN
  121. * EOF: Chgcase.cmd
  122.  
  123.